home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / vmsnet / util_olb.shr < prev    next >
Encoding:
Internet Message Format  |  1992-02-26  |  32.0 KB

  1. Path: uunet!wupost!waikato.ac.nz!ccc_rex
  2. From: ccc_rex@waikato.ac.nz
  3. Newsgroups: vmsnet.sources.games
  4. Subject: Missing UTIL.OLB sources for QIX (and other games)
  5. Message-ID: <1992Feb27.141509.6694@waikato.ac.nz>
  6. Date: 27 Feb 92 14:15:09 +1300
  7. Organization: University of Waikato, Hamilton, New Zealand
  8. Lines: 1077
  9.  
  10. These are the routines that make up the UTIL.OLB that is missing from the
  11. QIX source that was recently posted.
  12.  
  13. I managed to get QIX to run but the screen was a mess on my X-terminal
  14. DECwindow session.  The VT52 mode probably works correctly on a real VTXXX 
  15. terminal.  The new version of QIX I have uses VT100 escape sequences.
  16.  
  17. *KEEP* these routines if you want to be able to LINK some of the other
  18. games I will be posting, including SNAKE and TANK.
  19.  
  20.         - Rex
  21.  
  22. $! ------------------ CUT HERE -----------------------
  23. $ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
  24. $!
  25. $! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
  26. $!   On 27-FEB-1992 14:09:49.40   By user CCC_REX 
  27. $!
  28. $! This VMS_SHARE Written by:
  29. $!    Andy Harper, Kings College London UK
  30. $!
  31. $! Acknowledgements to:
  32. $!    James Gray       - Original VMS_SHARE
  33. $!    Michael Bednarek - Original Concept and implementation
  34. $!
  35. $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
  36. $! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
  37. $!
  38. $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
  39. $!       1. IMAGEDIR.MAR;6
  40. $!       2. SLEEP.MAR;1
  41. $!       3. TTIO.MAR;40
  42. $!       4. UTIL.COM;3
  43. $!
  44. $set="set"
  45. $set symbol/scope=(nolocal,noglobal)
  46. $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
  47. $e="write sys$error  ""%UNPACK"", "
  48. $w="write sys$output ""%UNPACK"", "
  49. $ if f$trnlnm("SHARE_LOG") then $ w = "!"
  50. $ ve=f$getsyi("version")
  51. $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
  52. $ e "-E-OLDVER, Must run at least VMS 4.4"
  53. $ v=f$verify(v)
  54. $ exit 44
  55. $UNPACK: SUBROUTINE ! P1=filename, P2=checksum
  56. $ if f$search(P1) .eqs. "" then $ goto file_absent
  57. $ e "-W-EXISTS, File ''P1' exists. Skipped."
  58. $ delete 'f'*
  59. $ exit
  60. $file_absent:
  61. $ if f$parse(P1) .nes. "" then $ goto dirok
  62. $ dn=f$parse(P1,,,"DIRECTORY")
  63. $ w "-I-CREDIR, Creating directory ''dn'."
  64. $ create/dir 'dn'
  65. $ if $status then $ goto dirok
  66. $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
  67. $ delete 'f'*
  68. $ exit
  69. $dirok:
  70. $ w "-I-PROCESS, Processing file ''P1'."
  71. $ if .not. f$verify() then $ define/user sys$output nl:
  72. $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
  73. PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
  74. SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
  75. CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
  76. LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
  77. BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
  78. IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
  79. MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
  80. ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
  81. 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
  82. POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
  83. ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
  84. COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
  85. "output_file"));ENDPROCEDURE;Unpacker;QUIT;
  86. $ delete/nolog 'f'*
  87. $ CHECKSUM 'P1'
  88. $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
  89. $ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
  90. $ ENDSUBROUTINE
  91. $START:
  92. $ create 'f'
  93. X`09.title`09imagedir`09find directory image was run from
  94. X
  95. X;+
  96. X;`09Modified 25-Jul-1985 to handle VMS V4 rooted directory specs
  97. X;-
  98. X
  99. X`09$jpidef
  100. X
  101. X`09.psect`09$code4`09rd, nowrt, exe, rel, pic, con, shr, long
  102. X
  103. Xlog:`09.ascii`09'IMAGE_DIR'
  104. Xlog_len = . - log
  105. X
  106. X`09.align`09word
  107. X`09.entry`09-
  108. Ximage_dir, `5Em<r2,r3,r4,r5>
  109. X;+
  110. X;`09status = image_dir()
  111. X;
  112. X;`09assigns the disk and directory that the current image is stored in
  113. X;`09to the logical "image_dir"
  114. X;
  115. X;`09status`09system service status code
  116. X;-
  117. X`09moval`09-(sp), r4`09`09; address of return length
  118. X`09subl2`09#256, sp`09`09; allocate room for image name
  119. X`09movl`09sp, r3`09`09`09; remember its address
  120. X
  121. X`09pushl`09#0`09`09`09; end of item list
  122. X`09pushl`09r4`09`09`09; return length address
  123. X`09pushl`09r3`09`09`09; buffer address
  124. X`09pushl`09#256!<jpi$_imagname@16> ; length and item code
  125. X`09movl`09sp, r1`09`09`09; address of item list
  126. X
  127. X`09$getjpi_s itmlst=(r1)`09`09; get info for this process
  128. X`09blbc`09r0, 1000$`09`09; br if error
  129. X
  130. X`09subl2`09#4*4, sp`09`09; remove item list from stack
  131. X;+
  132. X;`09now search for end of directory name ("`5D" or ">")
  133. X;-
  134. X`09movzwl`09(r4), r4`09`09; get full length of image name
  135. X`09movl`09r3, r5`09`09`09; get address
  136. X10$:
  137. X`09locc`09#`5EA/:/, r4, (r5)`09; look for end of logical name
  138. X`09beql`0920$`09`09`09; br if not found
  139. X
  140. X`09subl3`09#1, r0, r4`09`09; get new length
  141. X`09addl3`09#1, r1, r5`09`09; get new address
  142. X`09brb`0910$`09`09`09; look for another colon
  143. X20$:
  144. X`09locc`09#`5EA/`5D/, r4, (r5)`09; find closing bracket
  145. X`09beql`0940$`09`09`09; br if not found
  146. X
  147. X`09subl3`09#1, r0, r4`09`09; get new length
  148. X`09addl3`09#1, r1, r5`09`09; get new address
  149. X`09brb`0920$`09`09`09; look for another "`5D"
  150. X40$:
  151. X`09locc`09#`5EA/>/, r4, (r5)`09; find closing bracket
  152. X`09beql`0960$`09`09`09; br if not found
  153. X
  154. X`09subl3`09#1, r0, r4`09`09; get new length
  155. X`09addl3`09#1, r1, r5`09`09; get new address
  156. X`09brb`0940$`09`09`09; look for another ">"
  157. X60$:
  158. X
  159. X100$:
  160. X`09pushl`09r3`09`09`09; address of eqlnam
  161. X`09subl3`09r3, r5, -(sp)`09`09; get length of eqlnam
  162. X`09movl`09sp, r2`09`09`09; save address of descriptor
  163. X
  164. X`09pushab`09W`5Elog`09`09`09; address of lognam
  165. X`09pushl`09#log_len`09`09; length of lognam
  166. X`09movl`09sp, r3`09`09`09; save address of descriptor
  167. X
  168. X`09$crelog_s tblflg=#2, lognam=(r3), eqlnam=(r2) ; create process logical
  169. X;`09blbc`09r0, 1000$`09`09; br if error
  170. X1000$:
  171. X`09ret`09`09`09`09; which will clean up the stack
  172. X
  173. X
  174. X`09.end
  175. $ CALL UNPACK IMAGEDIR.MAR;6 173433367
  176. $ create 'f'
  177. X`09.title`09SLEEP - delay for specified interval
  178. X`09$ssdef`09`09`09; want ss$_insfarg
  179. X`09.psect`09$code`09pic, shr, rd, nowrt, exe
  180. X`09.entry`09-
  181. Xsleep, `5Em<r2, r3>
  182. X; Subroutine Sleep(Seconds, Fraction)
  183. X; Integer*4 Seconds, Fraction
  184. X`09seconds = 4`09`09; param offset
  185. X`09fraction = 8`09`09; optional fraction, in 100 ns units
  186. X`09sleep_efn = 0`09`09; which event flag to use
  187. X`09cmpb`09(ap), #1`09; how many args?
  188. X`09beqlu`092100$
  189. X`09bgtru`092200$
  190. X`09movl`09#ss$_insfarg, r0 ; none - error
  191. X`09brb`099000$
  192. X2100$:`09clrl`09r1`09`09; one arg, so fraction part is zero
  193. X`09brb`092900$
  194. X2200$:`09mnegl`09@fraction(ap), r1 ; else get fraction part
  195. X2900$:`09mnegl`09@seconds(ap), r0 ; make negative
  196. X`09emul`09#10000000, r0, r1, r2`09; convert to proper units in r2, r3
  197. X`09movq`09r2, -(sp)`09; push time onto stack
  198. X`09movaq`09(sp), r2`09; remember address
  199. X`09$setimr_s-`09`09; set timer
  200. X`09`09efn=#sleep_efn,-
  201. X`09`09daytim=(r2)`09; address of time value
  202. X`09blbc`09r0, 9000$
  203. X`09$waitfr_s-`09`09; wait for timer
  204. X`09`09efn=#sleep_efn
  205. X9000$:`09ret`09`09`09; done
  206. X
  207. X`09.end
  208. $ CALL UNPACK SLEEP.MAR;1 1182597876
  209. $ create 'f'
  210. X`09.title`09TTIO`09Terminal IO routines ($QIO's)
  211. X;+
  212. X;`09Routines to do IO via $QIO's to get special features.
  213. X;-
  214. X.if ne 0
  215. X1 TTIO
  216. XThis is a group of routines to enable you to perform efficient/special
  217. Xinput and/or output to a terminal.
  218. X2 TT_INIT
  219. XCALL TT_INIT( type )
  220. X
  221. X"type" is an integer variable which indicates the input you wish.
  222. X
  223. X"type" = 0  ordinary line input
  224. X         1  efficient single character input if available
  225. X         2  line input with escape sequences
  226. X2 TT_SET_FUNC
  227. XSets the read function modifiers and the wait time.  Once set, the options
  228. Xwill stay in effect until changed.
  229. X
  230. XINTEGER TT_SET_FUNC
  231. X
  232. XI = TT_SET_FUNC( value `5B, seconds `5D )
  233. X
  234. X"value" is a bit encoded integer specifying options required
  235. X  Symbol      Hex value         Description
  236. XIO$M_NOFILTR   '0200'X  Ctrl/U, Ctrl/R or Delete are passed to the user
  237. XIO$M_PURGE     '0800'X  Type-ahead buffer is purged before the read
  238. XIO$M_TIMED     '0080'X  Read must complete within specified time
  239. XIO$M_TRMNOECHO '1000'X  The terminator character (if any) is not echoed
  240. X
  241. X"seconds"  maximum time a read may take in seconds
  242. X"I" is the IO completion status code
  243. X2 TT_SET_READF
  244. XSets the buffer address and length before calling TT_SET_READF.
  245. X
  246. XINTEGER FUNCTION TT_SET_READF( buffer, buf_len )
  247. X
  248. Xbuffer`09address of buffer or address of descriptor of buffer
  249. Xbuf_len length of buffer.  If omitted then "buffer" is a descriptor
  250. X
  251. XValue of function is the I/O status completion code
  252. X2 TT_SET_TERM
  253. XSet terminator character mask
  254. X
  255. XCALL TT_SET_TERM( option, parameters... )
  256. X
  257. Xoption
  258. X  0`09normal terminators (any control char except LF VT FF TAB BS
  259. X  1`09parameter 1 is the address of a longword containing the
  260. X   `09terminator bit mask (first 32 characters only)
  261. X   `09eg. CALL TT_SET_TERM( 1, '00000001'X )
  262. X   `09    enable Control A as terminator
  263. X  2`09parameter 1 is address of # of bytes in terminator mask
  264. X   `09parameter 2 is address of array containing terminator bit mask
  265. X  3`09the following parameters are addresses of a byte containing
  266. X   `09the acsii code of the character to be a terminator.
  267. X   `09eg. CALL TT_SET_TERM( 3, 10, 13 )
  268. X   `09    enable LF and CR to be terminators
  269. X2 TT_CTRLCAST
  270. X
  271. XCALL TT_CTRLCAST( subroutine )
  272. X
  273. XThis causes the next control C to call the named routine.
  274. X2 TT_1_CHAR
  275. XINTEGER TT_1_CHAR
  276. X
  277. XI = TT_1_CHAR()
  278. X
  279. X"I" contains the ascii value of the character typed.
  280. XThis routine waits for the character and then returns it.
  281. XWhatever options that are set (see TT_SET_OPTION) are applied. (not true)
  282. X2 TT_1_CHAR_T
  283. XINTEGER TT_1_CHAR_T
  284. X
  285. XI = TT_1_CHAR_T( seconds )
  286. X
  287. XThis routine reads 1 character if typed within "seconds" time.
  288. X"I" contains the ascii value of the character typed,
  289. X it is 0 if the read timed out.
  290. X2 TT_1_CHAR_NOW
  291. XINTEGER TT_1_CHAR_NOW
  292. X
  293. XI = TT_1_CHAR_NOW()
  294. X
  295. X"I" contains the ascii value of the character typed, or -1 if no
  296. Xcharacter is available.  The character is not echoed.
  297. XThis routine returns immediately.
  298. X2 TT_READ
  299. XThis routine reads a line from the terminal.
  300. X
  301. XINTEGER TT_READ
  302. XI = TT_READ( buffer, buf_len, data_len `5B, term_len `5D )
  303. X  or
  304. XI = TT_READ( buf_desc, , data_len `5B, term_len `5D )
  305. X
  306. X"buffer" is the address of the input buffer
  307. X"buf_len" is the length of the input buffer in bytes
  308. X"data_len" will contain the number of characters read
  309. X"term_len" (if specified) will contain the length of the terminator
  310. X"I" will contain the IO completion status code
  311. X
  312. X"buf_desc" is the address of a descriptor of the input buffer
  313. X
  314. X2 TT_READF
  315. X
  316. XINTEGER FUNCTION TT_READF( data_len )
  317. Xdata_len length of data read (# of characters) (not including term)
  318. X
  319. XThis routine is used for reading a lot of data (presumably with
  320. Xecho reset). READF stands for READ FAST.
  321. XTT_READF_SET must be called first.
  322. X
  323. XValue of function is the I/O status completion code
  324. X2 TT_PROMPT
  325. XThis routine reads a line from the terminal.
  326. X
  327. XINTEGER TT_PROMPT
  328. XI = TT_PROMPT( prompt, prompt_len, buffer, buf_len, data_len
  329. X`09`09`09`09`09`09`5B, term_len `5D )
  330. X  or
  331. XI = TT_PROMPT( prompt_desc, , buf_desc, , data_len `5B, term_len `5D )
  332. X
  333. X"prompt" is the address of a character string
  334. X"prompt_len" is the length of the prompt character string
  335. X"buffer" is the address of the input buffer
  336. X"buf_len" is the length of the input buffer in bytes
  337. X"data_len" will contain the number of characters read
  338. X"term_len" (if specified) will contain the length of the terminator
  339. X"I" will contain the IO completion status code
  340. X
  341. X"prompt_desc" is the address of a descriptor of the prompt string
  342. X"buf_desc" is the address of a descriptor of the input buffer
  343. X
  344. X2 TT_WRITE
  345. XCALL TT_WRITE( array, length )
  346. XINTEGER length
  347. XBYTE array( length )
  348. X
  349. X"array" is the address of the characters
  350. X"length" is the number of characters to write
  351. X
  352. XThe write is done in "noformat" (binary) mode.  This completely bypasses
  353. Xany checking done by the terminal driver eg. for tabs, escape sequences,
  354. Xor end of line wrapping. `20
  355. X2 TT_WRITE_S
  356. XCALL TT_WRITE( array, length, efn )
  357. XINTEGER length, efn
  358. XBYTE array( length )
  359. X
  360. X"array" is the address of the characters
  361. X"length" is the number of characters to write
  362. X"efn" is the efn which will be set upon the writes completion
  363. X`09This routine does not wait for it to be set.
  364. X
  365. XCan be called synchronously with TT_WRITE.
  366. XThis is so that you can do 2 writes at the same time.
  367. XIt is designed for use within an AST procedure.
  368. X2 TT_CANCEL
  369. XCALL TT_CANCEL
  370. X
  371. XCancels type-ahead.
  372. X2 TT_CANCEL_IO
  373. XCALL TT_CANCEL_IO
  374. X
  375. XCancels all pending I/O requests that were issued via the TTIO routines.
  376. XThis will normally be called from within an AST procedure.
  377. X2 Examples
  378. XC`09TEST TTIO ROUTINES
  379. XC
  380. X`09INTEGER TT_PROMPT
  381. X`09CHARACTER PROMPT*16, BUF_IN*80
  382. X`09DATA PROMPT / 'ABCDEFGHIJKLMNO>' /
  383. XC
  384. X`09CALL TT_INIT( 2 )
  385. XC
  386. X`09DO J=1,10
  387. X`09  I = TT_PROMPT( PROMPT, , BUF_IN, , LEN_IN , LEN_TERM )
  388. X`09  TYPE *,I,LEN_IN, LEN_TERM
  389. X`09  TYPE *,BUF_IN(:LEN_IN)`09! THE TERMINATOR IS AFTER THIS
  390. X`09END DO
  391. X`09END
  392. X1 SLEEP_SET
  393. XThis routine, along with SLEEP_START and SLEEP_WAIT, allows your program
  394. Xto execute an asynchronous sleep.  You call SLEEP_SET to specify the length
  395. Xof time.  Then you call SLEEP_START to begin the timed period.  Control
  396. Xreturns immediately to your image; you can then execute whatever code is
  397. Xrequired.  Then you call SLEEP_WAIT to wait for the timed period to expire.
  398. XThe timed period may have already finished, in which case control will
  399. Xreturn immediately.
  400. X2 Parameters
  401. XCALL SLEEP_SET( time , efn )
  402. X
  403. X"time" is the address of an integer specifying the timed period in
  404. X       hundredths of a second.
  405. X"efn"  is the address of an integer indicating which event flag to use.
  406. X       Use 21 if you have no preference.  Must be less than 24.
  407. X1 SLEEP_START
  408. XThis starts a timed period, as specified by the previous call to SLEEP_SET.
  409. X
  410. XCALL SLEEP_START
  411. X
  412. XControl returns immediately.
  413. X1 SLEEP_WAIT
  414. XThis waits for the completion of a timed period, as started by the previous
  415. Xcall to SLEEP_START
  416. X
  417. XCALL SLEEP_WAIT
  418. X.endc
  419. X`09$dibdef
  420. X`09$iodef`09`09; qio io$_...
  421. X`09$ttdef`09`09; terminal characteristics
  422. X
  423. X
  424. X`09.psect`09$rw_TT_channel$ wrt, rd, noexe, noshr, pic, long
  425. Xttchan:
  426. X`09.long`09; channel on which terminal is open (if non zero)
  427. X
  428. X`09.psect`09$rodata`09nowrt, noexe, shr, pic, long
  429. X
  430. Xttname_descr:
  431. X`09.ascid`09/TT/
  432. X
  433. Xmbxcnv:
  434. X`09.ascid`09/_MBA!UW:/`09; convert mbx unit number to physical name
  435. X
  436. Xmbxbuf_descr:
  437. X`09.word`09mbxbuf_siz, 0
  438. X`09.address mbxbuf
  439. X
  440. Xdibbuf_descr:
  441. X`09.word`09dib$k_length, 0
  442. X`09.address dibbuf
  443. X
  444. X`09.align long
  445. X
  446. X`09.psect`09$rwbuf`09wrt, noexe, noshr, pic, long
  447. X
  448. Xmbxname_len = 16
  449. Xmbxname:`09`09`09; room to hold the physical mbx name
  450. X`09.blkb`09mbxname_len
  451. Xmbxname_descr:
  452. X`09.word`09mbxname_len, 0
  453. X`09.address mbxname
  454. Xmbxiosb:
  455. X`09.long`090,0
  456. Xmbxbuf_siz = 32
  457. Xmbxbuf:
  458. X`09.blkb`09mbxbuf_siz
  459. X
  460. Xdibbuf:
  461. X`09.blkb`09dib$k_length
  462. X
  463. X`09.align`09long
  464. Xttbuf_siz = 128
  465. Xttbuf:
  466. X`09.blkb`09ttbuf_siz
  467. X;outbuf_siz = 128
  468. X;outbuf::
  469. X;`09.blkb`09outbuf_siz
  470. X
  471. Xttiosb:
  472. X`09.long`090,0
  473. Xtt_func:
  474. X`09.long`09io$_readvblk
  475. Xtt_p_func:
  476. X`09.long`09io$_readprompt
  477. Xtt_timed:
  478. X`09.long`09`09`09; wait time if specified
  479. Xtt_term_addr:
  480. X`09.long`09`09`09; p4 parameter of read
  481. Xtt_term_quad:
  482. X`09.quad`09`09`09; quad word pointed to be tt_term_addr
  483. Xtt_term_mask:
  484. X`09.blkb`0916`09`09; bit set if that char is a terminator (0-127)
  485. X
  486. X
  487. X`09.psect`09$rwdata`09wrt, noexe, noshr, pic, long
  488. X
  489. Xmbxchan:
  490. X`09.word
  491. Xdata_ready:
  492. X`09.word
  493. X
  494. Xchars_left:
  495. X`09.long
  496. Xchar_pointer:
  497. X`09.long
  498. X
  499. Xsleep_time:
  500. X`09.long -100000*30, -1`09`09; time to sleep (30/100ths default)
  501. X
  502. Xttmode:`09`09`09`09`09; terminal chars changed
  503. X`09.quad
  504. Xttsavemode:`09`09`09`09; original terminal characteristics
  505. X`09.quad
  506. X
  507. Xsleep_args:
  508. X`09.long`094
  509. Xsleep_efn:
  510. X`09.long`0921`09; event flag to use for sleeps
  511. X`09.address sleep_time
  512. X`09.long`090`09; astadr
  513. X`09.long`090`09; reqidt
  514. X
  515. X;outbuf_qio:
  516. X;`09$qio`09func=io$_writevblk!io$m_noformat,-
  517. X;`09`09p1=outbuf
  518. Xoutput_qio:
  519. X`09$qio`09func=io$_writevblk!io$m_noformat
  520. X
  521. Xread_now_qio:
  522. X`09$qio`09func=io$_readvblk!io$m_timed!io$m_noecho!io$m_nofiltr,-
  523. X`09`09iosb=ttiosb,-
  524. X`09`09p1=ttbuf, p2=ttbuf_siz, p3=0`09; wait time = 0
  525. X
  526. Xread_fast_qio:`09; inittialized by TT_SET_READF
  527. X`09$qio`09func=io$_ttyreadall!io$m_noecho, iosb=ttiosb
  528. X
  529. Xtt_exit_blk:`09`09`09; exit handler block
  530. X`09.long
  531. X`09.address tt_exit_handler
  532. X`09.long`091`09`09; 1 argument
  533. X`09.address 10$
  534. X10$:`09.long`090`09`09; exit reason
  535. X
  536. X
  537. X`09.psect`09$code`09nowrt, exe, shr, pic
  538. X
  539. X`09.entry`09-
  540. XTT_INIT, `5Em<r2>
  541. X;+
  542. X; CALL TT_INIT( type )
  543. X; type`09= 0, ordinary line input
  544. X;`09  1, single character input
  545. X;`09  2, line input with escape sequences
  546. X;
  547. X;`09patch 16-Sep-1982
  548. X;`09`09Only allow 1 call to TT_INIT
  549. X;-
  550. X`09tstw`09ttchan`09`09; if channel already allocated, return
  551. X`09beql`0950$`09`09; patch 16-Sep-1982
  552. X`09ret
  553. X50$:
  554. X`09movl`09@4(ap), r2`09; get type code
  555. X
  556. X`09caseb`09r2, #0, #2
  557. X20$:`09.word`09100$-20$
  558. X`09.word`09200$-20$
  559. X`09.word`09300$-20$
  560. X100$:`09; type 0 (line input)
  561. X`09$assign_s`09devnam=ttname_descr, chan=ttchan
  562. X`09bsbw`09error`09`09`09; check for error
  563. X`09brw`091000$
  564. X
  565. X200$:`09; type 1 (single character input)
  566. X; Create a mailbox.  Assign a channel to terminal with an associated mailbox
  567. V.
  568. X`09$crembx_s`09chan=mbxchan, promsk=#`5ExFF00
  569. X`09bsbw`09`09error
  570. X`09$getchn_s`09chan=mbxchan, pribuf=dibbuf_descr
  571. X`09bsbw`09`09error
  572. X`09$fao_s`09`09ctrstr=mbxcnv, outbuf=mbxname_descr,-
  573. X`09`09`09outlen=mbxname_descr, p1=dibbuf+dib$w_unit
  574. X`09$assign_s`09devnam=ttname_descr, chan=ttchan, acmode=#`5ExFF00,-
  575. X`09`09`09mbxnam=mbxname_descr
  576. X`09bsbw`09error
  577. X`09bsbw`09queue_mbxread`09`09; start mail box read
  578. X`09brw`091000$
  579. X
  580. X300$:`09; type 2 (line input with escape sequences)
  581. X`09$assign_s`09devnam=ttname_descr, chan=ttchan
  582. X`09bsbw`09error`09`09`09; check for error
  583. X`09$qiow_s func=#io$_sensemode, chan=ttchan, -
  584. X`09`09iosb=ttiosb, p1=ttmode`09; get terminal characteristics
  585. X`09bsbw`09error
  586. X`09movzwl`09ttiosb, r0
  587. X`09bsbw`09error
  588. X`09movq`09ttmode, ttsavemode`09; save current terminal chars
  589. X`09$dclexh_s desblk=tt_exit_blk`09; declare exit handler to restore
  590. X`09`09`09`09`09; terminal chars on exit.
  591. X`09bsbw`09error
  592. X`09bbss`09#tt$v_escape, ttmode+4, 310$`09; want escape sequences
  593. X310$:`09$qiow_s func=#io$_setmode, chan=ttchan, -
  594. X`09`09iosb=ttiosb, p1=ttmode
  595. X`09bsbw`09error
  596. X`09movzwl`09ttiosb, r0
  597. X`09bsbw`09error
  598. X;`09brbw`091000$
  599. X
  600. X1000$:
  601. X;`09movw`09ttchan, outbuf_qio+qio$_chan`09`09;store channel #
  602. X`09movw`09ttchan, output_qio+qio$_chan`09`09;store channel #
  603. X`09movw`09ttchan, read_now_qio+qio$_chan`09`09;store channel #
  604. X;`09$qiow_s`09func=#io$_setmode!io$m_ctrlcast, chan=ttchan,-
  605. X;`09`09p1=control_c`09`09`09; set control C trap
  606. X`09ret
  607. X
  608. X
  609. X`09.entry`09-
  610. XTT_SET_FUNC, `5Em<>
  611. X;+
  612. X;`09I = TT_SET_FUNC( value `5B, seconds `5D )
  613. X;`09set read modifiers
  614. X;-
  615. X`09movl`09@4(ap), r0`09`09`09; get modifiers
  616. X`09movl`09#io$m_nofiltr!io$m_purge!io$m_timed!io$m_trmnoecho, r1
  617. X`09`09`09`09`09; get bits allowed to set
  618. X`09bicl2`09r1, tt_func`09`09; clear previous options
  619. X`09bicl2`09r1, tt_p_func
  620. X`09mcoml`09r1, r1`09`09`09; get bits cannot change
  621. X`09bicl2`09r1, r0`09`09`09; make sure only change correct bits
  622. X`09bisl2`09r0, tt_func`09`09; and set new options
  623. X`09bisl2`09r0, tt_p_func
  624. X
  625. X`09cmpb`09#1, (ap)`09`09; check if "seconds" parameter here
  626. X`09bgtr`09100$
  627. X`09ret
  628. X100$:`09movl`09@8(ap), tt_timed`09; store time
  629. X`09ret
  630. X
  631. X
  632. X`09.entry`09-
  633. XTT_SET_TERM, `5Em<r2,r3>
  634. X;+
  635. X;`09CALL TT_SET_TERM( option, parameters... )
  636. X;`09set terminator character mask
  637. X;
  638. X;`09option
  639. X;`090`09normal terminators (any control char except LF VT FF TAB BS
  640. X;`091`09parameter 1 is the address of a longword containing the
  641. X;`09`09terminator bit mask (first 32 characters only)
  642. X;`09`09( 1, '00000001'X )`09! enable Control A as terminator
  643. X;`092`09parameter 1 is address of # of bytes in terminator mask
  644. X;`09`09parameter 2 is address of array containing terminator bit mask
  645. X;`093`09the following parameters are addresses of a byte containing
  646. X;`09`09the acsii code of the character to be a terminator.
  647. X;`09`09( 3, 10, 13 )`09`09! enable LF and CR to be terminators
  648. X;-
  649. X`09subl3`09#1, (ap)+, r0`09`09; get number of parameters - 1
  650. X`09movl`09@(ap)+, r1`09`09; get option
  651. X
  652. X`09caseb`09r1, #0, #3
  653. X10$:`09.word`09100$-10$
  654. X`09.word`09200$-10$
  655. X`09.word`09300$-10$
  656. X`09.word`09400$-10$
  657. X; fall thru to option 0
  658. X100$:
  659. X`09clrl`09tt_term_addr`09`09; 0 means the default term mask
  660. X`09ret
  661. X200$:`09; option 1
  662. X`09sobgeq`09r0, 210$`09`09; see if another parameter
  663. X`09ret
  664. X210$:`09movl`09@(ap)+, r3`09`09; get longword terminator mask
  665. X240$:`09; r3 contains low 32 bits of terminator mask
  666. X`09clrl`09r2`09`09`09; first longword must be zero
  667. X`09movq`09r2, tt_term_quad`09; store it
  668. X250$:`09movaq`09tt_term_quad, tt_term_addr ; set up pointer to quadword
  669. X`09ret
  670. X
  671. X300$:`09; option 2`09; param1 is # of bytes`09; param2 if address of bytes
  672. X`09sobgeq`09r0, 310$`09`09; see if another parameter
  673. X`09ret
  674. X310$:`09movzbl`09@(ap)+, tt_term_quad`09; store # of bytes in term mask
  675. X`09sobgeq`09r0, 320$`09`09; see if another parameter
  676. X`09ret
  677. X320$:`09movl`09@(ap)+, tt_term_quad+4`09; store address of term bit mask
  678. X`09brb`09250$`09`09`09; go set up pointer and exit
  679. X
  680. X400$:`09; option 3`09; a list of ascii codes follow
  681. X`09movab`09tt_term_mask, r3`09; base of terminator bit mask
  682. X`09movl`09r3, r1
  683. X`09clrq`09(r1)+`09`09`09; zero terminator bit mask
  684. X`09clrq`09(r1)+`09`09`09; 16 bytes (0-127)
  685. X`09clrq`09(r1)+
  686. X`09clrq`09(r1)+
  687. X`09clrl`09r1`09`09`09; maximum ascii code
  688. X`09clrl`09r2`09`09`09; we put ascii code in low byte
  689. X`09tstl`09r0`09`09`09; see if at least 1 parameter
  690. X`09bgtr`09410$
  691. X`09ret
  692. X410$:
  693. X`09bicb3`09#`5EX80, @(ap)+, r2`09; get ascii code (0-127)
  694. X`09cmpl`09r2, r1`09`09`09; bigger than previous maximum ?
  695. X`09bleq`09420$
  696. X`09movl`09r2, r1
  697. X420$:`09bbss`09r2, (r3), 440$`09`09; set bit
  698. X440$:`09sobgtr`09r0, 410$`09`09; do all parameters
  699. X
  700. X`09addl2`09#7, r1`09`09`09; round up to nearest byte
  701. X`09divl2`09#8, r1`09`09`09; get # of bytes in term mask
  702. X`09cmpl`09r1, #4`09`09`09; if <= 4 bytes, use short format
  703. X`09bgtr`09450$
  704. X`09movl`09(r3), r3`09`09; get first 4 bytes of mask in r3
  705. X`09brw`09240$`09`09`09; go store it and pointer and exit
  706. X450$:
  707. X`09movl`09r1, tt_term_quad`09; store # of bytes for long format
  708. X`09movl`09r3, tt_term_quad+4`09; store address of term bit mask
  709. X`09brb`09250$`09`09`09; store pointer and exit
  710. X
  711. X
  712. X
  713. X`09.entry`09-
  714. XTT_CTRLCAST,`09`5Em<>
  715. X;+
  716. X;`09CALL TT_CTRLCAST( routine address )
  717. X;`09enable a control C ast
  718. X;-
  719. X`09$qiow_s func=#io$_setmode!io$m_ctrlcast, chan=ttchan, iosb=ttiosb, -
  720. X`09`09p1=@4(ap)
  721. X`09ret`09`09`09`09; ignore all erros
  722. X
  723. X
  724. X`09.entry`09-
  725. XTT_1_CHAR,`09`5Em<>
  726. X;+
  727. X;`09I = TT_1_CHAR
  728. X;`09read 1 character.  Waits for it.
  729. X;-
  730. X`09clrb`09ttbuf
  731. X`09$qiow_s`09func=#io$_readvblk!io$m_noecho!io$m_nofiltr,-
  732. X`09`09chan=ttchan, iosb=ttiosb,-
  733. X`09`09p1=ttbuf, p2=#1
  734. X`09cvtbl`09ttbuf, r0
  735. X`09ret
  736. X
  737. X`09.entry`09-
  738. XTT_1_CHAR_T,`09`5Em<>
  739. X;+
  740. X;`09I = TT_1_CHAR_T( seconds )
  741. X;`09read 1 character.  Waits "seconds" for it.
  742. X;`09returns 0 if times out
  743. X;-
  744. X`09clrb`09ttbuf
  745. X`09$qiow_s`09func=#io$_readvblk!io$m_noecho!io$m_nofiltr!io$m_timed,-
  746. X`09`09chan=ttchan, iosb=ttiosb,-
  747. X`09`09p1=ttbuf, p2=#1, p3=@4(ap)
  748. X`09cvtbl`09ttbuf, r0
  749. X`09ret
  750. X
  751. X`09.entry`09-
  752. XTT_1_CHAR_NOW, `5Em<>
  753. X;+
  754. X;`09I = TT_1_CHAR_NOW()
  755. X;`09get next character if typed.  Returns immediately.
  756. X;`09I = -1 if no character available
  757. X;-
  758. X`09tstl`09chars_left`09`09; have we used all characters ?
  759. X`09bgtr`0950$`09`09`09; no --> 50$
  760. X`09bbsc`09#0, data_ready, 20$`09; check if input ready
  761. X5$:`09mnegl`09#1, r0`09`09`09; no characters read
  762. X`09ret`09`09`09`09; no
  763. X20$:
  764. X`09$qiow_g read_now_qio
  765. X`09blbc`09r0, 5$`09`09`09; error
  766. X;
  767. X;`09$qiow_s`09func=#io$_writevblk,chan=ttchan,-`09; debug write
  768. X;`09`09p1=ttbuf, p2=ttiosb+2, p4=#`5Ex1000
  769. X
  770. X`09movzwl`09ttiosb+2, chars_left`09`09; # chars read
  771. X`09movab`09ttbuf, char_pointer`09`09; store address of character
  772. X50$:
  773. X`09decl`09chars_left
  774. X`09movzbl`09@char_pointer, r0`09`09; get next char
  775. X`09incl`09char_pointer`09`09`09; point to next
  776. X`09ret
  777. X
  778. X
  779. X`09.entry`09-
  780. XTT_READ, `5Em<r2,r3>
  781. X;+
  782. X;`09INTEGER FUNCTION TT_READ( buffer, buf_len, data_len, term_len )
  783. X;`09buffer`09address of buffer or address of descriptor of buffer
  784. X;`09buf_len length of buffer.  If omitted then "buffer" is a descriptor
  785. X;`09data_len length of data read (# of characters)
  786. X;`09term_len length of terminator
  787. X;
  788. X;`09Value of function is the I/O status completion code
  789. X;-
  790. X`09movl`098(ap), r2`09`09; get buf_len
  791. X`09bneq`09100$`09`09`09; if <> 0 then it was specified
  792. X`09movq`09@4(ap), r2`09`09; get descriptor of buffer
  793. X`09`09`09`09`09; r2 = length, r3 = address
  794. X`09bicl2`09#`5EXFFFF0000, r2`09`09; want length only
  795. X`09brb`09200$
  796. X100$:
  797. X`09movl`09(r2), r2`09`09; get buffer length
  798. X`09movl`094(ap), r3`09`09; get buffer address
  799. X200$:
  800. X`09$qiow_s func=tt_func, chan=ttchan, iosb=ttiosb, -
  801. X`09`09p1=(r3), p2=r2, p3=tt_timed, p4=tt_term_addr
  802. X`09blbc`09r0, 600$`09`09; did $qio get an error.  yes --> 600$
  803. X
  804. X`09movzwl`09ttiosb+2, @12(ap)`09; store # characters read
  805. X`09cmpb`09(ap), #3`09`09; enough arguments supplied
  806. X`09bleq`09500$`09`09`09; no --> 500$
  807. X`09movl`0916(ap), r2`09`09; does user want terminator length
  808. X`09beql`09500$
  809. X`09movzwl`09ttiosb+6, (r2)`09`09; store terminator length
  810. X500$:
  811. X`09movzwl`09ttiosb, r0
  812. X600$:
  813. X`09ret
  814. X
  815. X
  816. X`09.entry`09-
  817. XTT_SET_READF, `5Em<r2,r3>
  818. X;+
  819. X;`09CALL TT_SET_READF( buffer, buf_len )
  820. X;`09buffer`09address of buffer or address of descriptor of buffer
  821. X;`09buf_len length of buffer.  If omitted then "buffer" is a descriptor
  822. X;-
  823. X`09movl`098(ap), r2`09`09; get buf_len
  824. X`09bneq`09100$`09`09`09; if <> 0 then it was specified
  825. X`09movq`09@4(ap), r2`09`09; get descriptor of buffer
  826. X`09`09`09`09`09; r2 = length, r3 = address
  827. X`09bicl2`09#`5EXFFFF0000, r2`09`09; want length only
  828. X`09brb`09200$
  829. X100$:
  830. X`09movl`09(r2), r2`09`09; get buffer length
  831. X`09movl`094(ap), r3`09`09; get buffer address
  832. X200$:
  833. X`09movl`09r3, read_fast_qio+qio$_p1`09; address of buffer
  834. X`09movl`09r2, read_fast_qio+qio$_p2`09; length of buffer
  835. X;`09movl`09tt_timed, read_fast_qio+qio$_p3 ; time out
  836. X`09movl`09tt_term_addr, read_fast_qio+qio$_p4 ; terminator pointer
  837. X;`09movl`09tt_func, read_fast_qio+qio$_func
  838. X`09movzwl`09ttchan, read_fast_qio+qio$_chan
  839. X
  840. X`09ret
  841. X
  842. X
  843. X`09.entry`09-
  844. XTT_READF, `5Em<r2,r3>
  845. X;+
  846. X;`09INTEGER FUNCTION TT_READF( data_len )
  847. X;`09data_len length of data read (# of characters) (not including term)
  848. X;
  849. X;`09This routine is used for reading a lot of data in binary mode
  850. X;`09with no echo.  READF stands for READ FAST.
  851. X;`09TT_READF_SET must be called first
  852. X;
  853. X;`09Value of function is the I/O status completion code
  854. X;-
  855. X
  856. X`09$qiow_g read_fast_qio
  857. X`09blbc`09r0, 600$`09`09; did $qio get an error.  yes --> 600$
  858. X
  859. X`09movzwl`09ttiosb+2, @4(ap)`09; store # characters read
  860. X`09movzwl`09ttiosb, r0
  861. X600$:
  862. X`09ret
  863. X
  864. X
  865. X`09.entry`09-
  866. XTT_PROMPT, `5Em<r2,r3,r4,r5>
  867. X;+
  868. X;`09INTEGER FUNCTION TT_PROMPT( prompt, prompt_len,
  869. X;`09`09buffer, buf_len, data_len, term_len )
  870. X;`09prompt  address of prompt string or address of descriptor
  871. X;`09prompt_len  length of prompt string.  If omitted then "prompt"
  872. X;`09`09`09`09`09`09is a descriptor
  873. X;`09buffer`09address of buffer or address of descriptor of buffer
  874. X;`09buf_len length of buffer.  If omitted then "buffer" is a descriptor
  875. X;`09data_len length of data read (# of characters)
  876. X;`09term_len length of terminator
  877. X;
  878. X;`09Value of function is the I/O status completion code
  879. X;-
  880. X`09movl`0916(ap), r2`09`09; get buf_len
  881. X`09bneq`09100$`09`09`09; if <> 0 then it was specified
  882. X`09movq`09@12(ap), r2`09`09; get descriptor of buffer
  883. X`09`09`09`09`09; r2 = length, r3 = address
  884. X`09bicl2`09#`5EXFFFF0000, r2`09`09; want length only
  885. X`09brb`09200$
  886. X100$:
  887. X`09movl`09(r2), r2`09`09; get buffer length
  888. X`09movl`0912(ap), r3`09`09; get buffer address
  889. X200$:
  890. X`09movl`098(ap), r4`09`09; get prompt_len
  891. X`09bneq`09300$`09`09`09; if <> 0 then it was specified
  892. X`09movq`09@4(ap), r4`09`09; get descriptor of prompt string
  893. X`09`09`09`09`09; r4 = length, r5 = address
  894. X`09bicl2`09#`5EXFFFF0000, r4`09`09; get length only
  895. X`09brb`09400$
  896. X300$:
  897. X`09movl`09(r4), r4`09`09; get prompt length
  898. X`09movl`094(ap), r5`09`09; get prompt address
  899. X400$:
  900. X
  901. X`09$qiow_s func=tt_p_func, chan=ttchan, iosb=ttiosb, -
  902. X`09`09p1=(r3), p2=r2, p3=tt_timed, p5=r5, p6=r4
  903. X`09blbc`09r0, 600$`09`09; did $qio get an error.  yes --> 600$
  904. X
  905. X`09movzwl`09ttiosb+2, @20(ap)`09; store # characters read
  906. X`09cmpb`09(ap), #5`09`09; enough arguments supplied
  907. X`09bleq`09500$`09`09`09; no --> 500$
  908. X`09movl`0924(ap), r2`09`09; does user want terminator length
  909. X`09beql`09500$
  910. X`09movzwl`09ttiosb+6, (r2)`09`09; store terminator length
  911. X500$:
  912. X`09movzwl`09ttiosb, r0
  913. X600$:
  914. X`09ret
  915. X
  916. X
  917. X`09.entry`09-
  918. XTT_MBX_READ,`09`5Em<>
  919. X;+
  920. X; This is an AST routine which executes when the mailbox record has been rea
  921. Vd.
  922. X; The record itself is a status message which is assumed to say that
  923. X; unsolicited data is available at the terminal
  924. X;-
  925. X`09blbc`09mbxiosb, 100$`09`09; on error, dont re-que read
  926. X;`09we could have SS$_CANCEL or SS$_ABORT from the $CANCEL in the
  927. X;`09exit handler
  928. X`09movb`09#1, data_ready`09`09; indicate data is there
  929. X`09bsbw`09queue_mbxread`09`09; queue another read request
  930. X100$:
  931. X`09ret
  932. X
  933. XQUEUE_MBXREAD:
  934. X`09$qio_s`09efn=#2, func=#io$_readvblk, chan=mbxchan, iosb=mbxiosb,-
  935. X`09`09astadr=tt_mbx_read,-
  936. X`09`09p1=mbxbuf, p2=#mbxbuf_siz
  937. X`09blbc`09r0, 100$
  938. X`09rsb
  939. X100$:
  940. X`09bsbw`09error
  941. X`09rsb
  942. X
  943. X;TT_WRITE$:
  944. X;+
  945. X;`09bsbw`09ttwrite
  946. X;`09r3 contains length of buffer to write
  947. X;`09the buffer is outbuf
  948. X;-
  949. X;`09movl`09r3, outbuf_qio+qio$_p2`09`09; store length of buffer
  950. X;`09$qiow_g`09outbuf_qio
  951. X;`09blbc`09r0, 100$
  952. X;`09rsb
  953. X;100$:
  954. X;`09bsbw`09error
  955. X;`09rsb
  956. X
  957. X`09.entry`09-
  958. XTT_WRITE, `5Em<>
  959. X;+
  960. X;`09CALL TT_WRITE( array, length )
  961. X;`09BYTE ARRAY( LENGTH )
  962. X;`09writes buffer to terminal in noformat mode
  963. X;-
  964. X`09movl`094(ap), output_qio+qio$_p1`09; store address of buffer
  965. X`09movl`09@8(ap), output_qio+qio$_p2`09; store length of buffer
  966. X`09$qiow_g`09output_qio
  967. X`09blbc`09r0, 100$
  968. X`09ret
  969. X100$:
  970. X`09bsbw`09error
  971. X`09ret
  972. X
  973. X`09.entry`09-
  974. XTT_WRITE_S, `5Em<>
  975. X;+
  976. X;`09CALL TT_WRITE_S( array, length, efn )
  977. X;`09BYTE ARRAY( LENGTH )
  978. X;`09writes buffer to terminal in noformat mode
  979. X;`09this puts the qio on the stack so that it can be called
  980. X;`09synchronously with TT_WRITE
  981. X;-
  982. X`09$qio_s func=#io$_writevblk!io$m_noformat, -
  983. X`09`09chan=ttchan, -
  984. X`09`09efn=@12(ap), -
  985. X`09`09p1=@4(ap), p2=@8(ap)
  986. X`09blbc`09r0, 100$
  987. X`09ret
  988. X100$:
  989. X`09bsbw`09error
  990. X`09ret
  991. X
  992. X`09.entry -
  993. XTT_CANCEL, `5Em<>
  994. X`09clrl`09r0
  995. X`09tstw`09ttchan`09`09; check channel is open
  996. X`09beql`09100$
  997. X`09$qiow_s`09func=#io$_readvblk!io$m_purge!io$m_timed,-
  998. X`09`09chan=ttchan, p1=ttbuf, p2=#0
  999. X;###`09`09`09; do read with 0 length buffer (p2)
  1000. X`09clrl`09chars_left`09; for TT_1_char_now
  1001. X`09clrl`09data_ready`09; say no data ready to read
  1002. X100$:
  1003. X`09ret`09`09`09; return with status in r0
  1004. X
  1005. X`09.entry -
  1006. XTT_CANCEL_IO, `5Em<>
  1007. X;+
  1008. X;`09cancels I/O on channel
  1009. X;-
  1010. X`09clrl`09r0
  1011. X`09tstw`09ttchan`09`09; check channel is open
  1012. X`09beql`09100$
  1013. X`09$cancel_s chan=ttchan
  1014. X`09bsbb`09error
  1015. X100$:`09ret`09`09`09; return with status in r0
  1016. X
  1017. XERROR:
  1018. X`09blbs`09r0, 100$
  1019. X`09pushl`09r0
  1020. X`09calls`09#1, G`5Elib$signal
  1021. X100$:
  1022. X`09rsb
  1023. X
  1024. X;`09.entry`09-
  1025. X;control_c, `5Em<>
  1026. X;`09movb`09#1, control_c_flag
  1027. X;`09ret
  1028. X
  1029. X
  1030. X`09.entry`09-
  1031. XSLEEP_SET, `5Em<>
  1032. X;+
  1033. X;`09CALL SLEEP_SET( efn , time )
  1034. X;`09INTEGER efn, time
  1035. X;`09use "efn" as event flag
  1036. X;`09sleep for "time" 100th's of a second
  1037. X;-
  1038. X`09movl`09@4(ap), sleep_efn
  1039. X`09emul`09#-100000, @8(ap), #0, sleep_time`09; get delta time format
  1040. X`09$setef_s efn=sleep_efn`09`09; set ef in case SLEEP_START not called
  1041. X`09ret
  1042. X
  1043. X`09.entry`09-
  1044. XSLEEP_START, `5Em<>
  1045. X;+
  1046. X;`09CALL SLEEP_START
  1047. X;`09starts a timer
  1048. X;-
  1049. X`09$setimr_g sleep_args
  1050. X`09blbc`09r0, 100$
  1051. X`09ret
  1052. X100$:`09bsbw`09error
  1053. X`09ret
  1054. X
  1055. X`09.entry`09-
  1056. XSLEEP_WAIT, `5Em<>
  1057. X;+
  1058. X;`09CALL SLEEP_WAIT
  1059. X;`09waits for sleep efn to turn on
  1060. X;-
  1061. X`09$waitfr_s efn=sleep_efn
  1062. X`09ret
  1063. X
  1064. Xtt_exit_handler = .
  1065. X`09.word`09`5Em<>
  1066. X`09$qiow_s func=#io$_setmode, chan=ttchan, iosb=ttiosb -
  1067. X`09`09p1=ttsavemode`09`09; reset terminal mode
  1068. X;`09if we get an error, too bad.
  1069. X`09ret
  1070. X
  1071. X`09.end
  1072. $ CALL UNPACK TTIO.MAR;40 1729311633
  1073. $ create 'f'
  1074. X$!
  1075. X$!`09Create  UTIL.OLB
  1076. X$!
  1077. X$ MACRO ttio
  1078. X$ MACRO sleep
  1079. X$ MACRO imagedir
  1080. X$!
  1081. X$ LIBR/CRE util ttio,sleep,imagedir
  1082. X$ SET FILE/TRUNC util.olb
  1083. X$!
  1084. $ CALL UNPACK UTIL.COM;3 1963740437
  1085. $ v=f$verify(v)
  1086. $ EXIT
  1087.